home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / FINDNEXT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  666 b   |  30 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <dir.h>
  4. main()
  5. {
  6.     int count;
  7.     long totalsize;
  8.     struct ffblk fileinfo;
  9.     if( findfirst("*.c", &fileinfo, 0) == -1)
  10.     {
  11.         printf("Unsuccessful findfirst call!\n");
  12.         exit(0);
  13.     }
  14.     printf("Listing of *.c files:\n");
  15.     printf("%12s  %8ld bytes\n", fileinfo.ff_name,
  16.                 fileinfo.ff_fsize);
  17.     count =1;
  18.     totalsize = fileinfo.ff_fsize;
  19.     while(findnext(&fileinfo) == 0)
  20.     {
  21.         count++;
  22.         totalsize += fileinfo.ff_size;
  23. /* Now print the name and size of each matching file */
  24.     printf("%12s  %8ld bytes\n",
  25.         fileinfo.ff_name, fileinfo.ff_fsize);
  26.     }
  27.     printf("\n%d files %ld bytes.\n", count, totalsize);
  28. }
  29.  
  30.